/********************************************
 * 功能说明: 
 * 模块名称: 
 * 系统名称: 
 * 软件版权: 北京银杉金服科技有限公司
 * 系统版本: 1.0.0
 * 开发人员: zhangfb
 * 开发时间: 2018/9/23 23:45
 * 审核人员: 
 * 相关文档: 
 * 修改记录: 修改日期 修改人员 修改说明
 *********************************************/
package com.hyacinth.controller;

import com.hyacinth.annotation.LogAnnotation;
import com.hyacinth.constant.LogTypeEnum;
import com.hyacinth.dto.OperationLogDto;
import com.hyacinth.service.LogService;
import com.hyacinth.util.validator.HyValidatorFactory;
import com.hyacinth.wapper.WrapMapper;
import com.hyacinth.wapper.Wrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 日志控制器
 * @author zhangfb
 * @version 1.0.0.1
 * @since JDK 1.8
 */
@Slf4j
@RestController
@RequestMapping(value = "base/log", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class LogController extends BaseController{

    private final LogService logService;

    @Autowired
    public LogController(LogService logService) {
        this.logService = logService;
    }

    /**
     * 新增日志
     * @param log 日志对象
     * @return 结果封装
     */
    @LogAnnotation(logType = LogTypeEnum.INTERFACE_LOG, isSaveReqData = true, isSaveRespData = true, desc = "新增日志")
    @RequestMapping(value = "", method = RequestMethod.POST)
    public Wrapper save(@RequestBody OperationLogDto log) {
        HyValidatorFactory.validate(log);
        logService.save(log);
        return WrapMapper.ok();
    }
}
